<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>AJAX 测试页面</title>
    <link rel="stylesheet" href="" th:href="@{/Jeff/css/common.css}">
    <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
    <script type="text/javascript" th:inline="javascript">
        var basePath = [[${#request.getContextPath()}]];

        function queryCount() {
            $.ajax({
                url: basePath + "/ajax/queryCount",
                method:'get',
                success: function (result) {
                    $('#queryCount').text(result);
                }
            });
        }

        function queryByName() {
            /*构建参数*/
            var params = {};
            params.chineseName = $('#name').val();
            params.aaa="bbb";
            $.post(
                basePath + "/ajax/queryByName",
                params,
                function (result) {
                    console.log(result);
                },"json"
            )
        }
    </script>
</head>
<body>
<p>student_info_20 表中共有:
    <button onclick="queryCount()"><span id="queryCount">?</span></button>
    条数据
</p>

<label>姓名: <input type="text" id="name" placeholder="请输入学生姓名"></label>

<button onclick="queryByName()">根据名字查询</button>

</body>
</html>